package com.example.leonard.core.mq.mqconfig;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class FanoutConfig {
    @Bean
    public Queue fanoutQueue() {
        return new Queue(MQConstants.FANOUTQUEUE);
    }

    @Bean
    public Queue fanoutQueues() {
        return new Queue(MQConstants.FANOUTQUEUES);
    }

    @Bean
    public FanoutExchange fanoutExchange() {
        return new FanoutExchange(MQConstants.FANOUTEXCHANGE);
    }

    @Bean
    public Binding bindingExchangeA() {
        return BindingBuilder.bind(fanoutQueue()).to(fanoutExchange());
    }

    @Bean
    public Binding bindingExchangeB() {
        return BindingBuilder.bind(fanoutQueues()).to(fanoutExchange());
    }
}
